<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title><!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>mixins</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
  <h1>mixins</h1>
  <hr>
  <div id="app">
    {{num}}
    <p><button @click="add">add</button></p>
  </div>
  <script type="text/javascript">
  var addConsole = {
    updated:function(){
      console.log('混入 data changed:'+this.num);
    }
  };
  Vue.mixin({
    updated:function(){
      console.log('全局的混入');
    }
  });
  var app = new Vue({
    el:'#app',
    data:{
      num:1
    },
    methods:{
      add:function(){
        this.num++;
      }
    },
    updated:function(){
      console.log('原生updated');
    },
    mixins:[addConsole]//混入先执行，原生后执行
  })
  </script>
</body>
</html>